-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
statistics: reduce allocation of types.Context #52615
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #52615 +/- ##
=================================================
- Coverage 72.3860% 55.6253% -16.7607%
=================================================
Files 1482 1593 +111
Lines 428754 598394 +169640
=================================================
+ Hits 310358 332859 +22501
- Misses 99088 242580 +143492
- Partials 19308 22955 +3647
Flags with carried forward coverage won't be shown. Click here to find out more.
|
293bc35
to
c648886
Compare
c648886
to
6ada327
Compare
/cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any test results? Could you please put it on GitHub?
pkg/domain/domain.go
Outdated
// Invalid date values may be inserted into table under some relaxed sql mode. Those values may exist in statistics. | ||
// Hence, when reading statistics, we should skip invalid date check. See #39336. | ||
sc := ctx.GetSessionVars().StmtCtx | ||
sc.SetTypeFlags(sc.TypeFlags().WithIgnoreInvalidDateErr(true).WithIgnoreZeroInDate(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a function for it? Then we don't need to copy the comments and code again in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any good ideas?
I'm not sure how to make it better(
pkg/session/session.go
Outdated
@@ -1838,6 +1838,7 @@ func (s *session) useCurrentSession(execOption sqlexec.ExecOption) (*session, fu | |||
prevSQL := s.sessionVars.StmtCtx.OriginalSQL | |||
prevStmtType := s.sessionVars.StmtCtx.StmtType | |||
prevTables := s.sessionVars.StmtCtx.Tables | |||
prevTypeFlags := s.sessionVars.StmtCtx.TypeFlags() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change? Could you explain a little bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useCurrentSession
will return a func as the clean
func after the session executes a SQL.
We need to make sure that the CLEAN operation will not clean the flag we set.
pkg/statistics/histogram.go
Outdated
@@ -1126,51 +1124,6 @@ func GetIndexPrefixLens(data []byte, numCols int) (prefixLens []int, err error) | |||
return prefixLens, nil | |||
} | |||
|
|||
// ExtractTopN extracts topn from histogram. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
The test env is under rebuilding( |
7c679bd
to
b6faed1
Compare
89487df
to
3a4f760
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that not all places use flags with FlagIgnoreInvalidDateErr
and FlagIgnoreZeroInDateErr
.
Others LGTM.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hawkingrei, time-and-fate The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/retest |
/cherrypick release-8.1 |
@winoros: new pull request created to branch In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: close #52342
Problem Summary:
We still have #52429, but we can reduce the allocations first.
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.